local TECH = GLOBAL.TECH

local TabMusha = AddRecipeTab("MUSHA", 12, "images/mushatab.xml", "mushatab.tex", "_musha", false)

local function musha_glowdust(amount)
	return Ingredient("musha_glowdust", amount, "images/inventoryimages/musha_glowdust.xml")
end

local musha_sword_base = Ingredient("musha_sword_base", 1, "images/inventoryimages/musha_sword_base.xml")
local musha_armor_original = Ingredient("musha_armor_original", 1, "images/inventoryimages/musha_armor_original.xml")

local function Gems_Recipes()
	if GetModConfigData("convertgem") then
		return {
			{
				name = "redgem",
				ingredients = {Ingredient("bluegem", 1), musha_glowdust(1)},
				level = TECH.NONE,
				autoico = true
			},
			{
				name = "bluegem",
				ingredients = {Ingredient("redgem", 1), musha_glowdust(1)},
				level = TECH.NONE,
				autoico = true
			}
		}
	else
		return {
			{
				name = "redgem",
				ingredients = {Ingredient("goldnugget", 4), Ingredient("feather_robin", 1), musha_glowdust(2)},
				level = TECH.SCIENCE_ONE,
				autoico = true
			},
			{
				name = "bluegem",
				ingredients = {Ingredient("goldnugget", 4), Ingredient("feather_robin_winter", 1), musha_glowdust(2)},
				level = TECH.SCIENCE_ONE,
				autoico = true
			}
		}
	end
end

local function Rare_Gems_Recipes()
	if GetModConfigData("raregemrecipes") then
		return {
			{
				name = "greengem",
				ingredients = {
					Ingredient("purplegem", 2),
					Ingredient("goldnugget", 4),
					musha_glowdust(3)
				},
				level = TECH.SCIENCE_TWO,
				autoico = true
			},
			{
				name = "yellowgem",
				ingredients = {
					Ingredient("purplegem", 2),
					Ingredient("goldnugget", 4),
					musha_glowdust(3)
				},
				level = TECH.SCIENCE_TWO,
				autoico = true
			},
			{
				name = "orangegem",
				ingredients = {
					Ingredient("purplegem", 2),
					Ingredient("goldnugget", 4),
					musha_glowdust(3)
				},
				level = TECH.SCIENCE_TWO,
				autoico = true
			}
		}
	else
		return {}
	end
end

local function Get_Bunnyhat_Recipes()
	if GetModConfigData("rabbitrecipe") then
		return {Ingredient("cutgrass", 6), Ingredient("bluegem", 1), Ingredient("deserthat", 1)}
	else
		return {Ingredient("cutgrass", 6), Ingredient("bluegem", 2), Ingredient("manrabbit_tail", 4)}
	end
end

local Musha_recipe = {
	{
		name = "musha_glowdust",
		ingredients = {
			Ingredient("ash", 1),
			Ingredient("honey", 5),
			Ingredient("musha_apple_cooked", 1, "images/inventoryimages/musha_apple_cooked.xml")
		},
		level = TECH.NONE
	},
	{
		name = "musha_cristal",
		ingredients = {
			musha_glowdust(3),
			Ingredient("purplegem", 1)
		},
		level = TECH.SCIENCE_ONE
	},
	Gems_Recipes()[1],
	Gems_Recipes()[2],
	Rare_Gems_Recipes()[1],
	Rare_Gems_Recipes()[2],
	Rare_Gems_Recipes()[3],
	{
		name = "musha_arrowm0",
		ingredients = {Ingredient("stinger", 1), Ingredient("feather_crow", 1)},
		product = "musha_arrowm",
		num = 3,
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_arrowm1",
		ingredients = {Ingredient("stinger", 1), Ingredient("feather_robin", 1)},
		product = "musha_arrowm",
		num = 3,
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_arrowm2",
		ingredients = {Ingredient("stinger", 1), Ingredient("feather_canary", 1)},
		product = "musha_arrowm",
		num = 3,
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_arrowm3",
		ingredients = {Ingredient("stinger", 2), Ingredient("feather_robin_winter", 1)},
		product = "musha_arrowm",
		num = 6,
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_arrowm",
		ingredients = {Ingredient("musha_arrowm_broken", 5, "images/inventoryimages/musha_arrowm_broken.xml")},
		num = 5,
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_sword_base",
		ingredients = {musha_glowdust(1), Ingredient("goldnugget", 2)},
		level = TECH.NONE
	},
	{
		name = "musha_sword_fire",
		ingredients = {
			musha_sword_base,
			Ingredient("redgem", 2),
			musha_glowdust(1)
		},
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_sword_frost",
		ingredients = {
			musha_sword_base,
			Ingredient("bluegem", 2),
			musha_glowdust(1)
		},
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_sword_long",
		ingredients = {
			Ingredient("musha_sword_frost", 1, "images/inventoryimages/musha_sword_frost.xml"),
			Ingredient("musha_sword_fire", 1, "images/inventoryimages/musha_sword_fire.xml"),
			Ingredient("goldnugget", 15),
			musha_glowdust(2)
		},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_bowm",
		ingredients = {
			Ingredient("musha_sword_fire", 1, "images/inventoryimages/musha_sword_fire.xml"),
			Ingredient("spidergland", 6),
			musha_glowdust(2)
		},
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_phoenixaxe",
		ingredients = {
			Ingredient("goldnugget", 80),
			Ingredient("purplegem", 6),
			Ingredient("greengem", 6),
			Ingredient("musha_cristal", 1, "images/inventoryimages/musha_cristal.xml")
		},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_frosthammer",
		ingredients = {
			Ingredient("deerclops_eyeball", 1),
			Ingredient("bluegem", 12),
			Ingredient("livinglog", 5),
			Ingredient("gears", 3)
		},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_flute",
		ingredients = {
			musha_glowdust(5),
			Ingredient("horn", 1),
			Ingredient("spidergland", 20)
		},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_armor_original",
		ingredients = {
			musha_glowdust(2),
			Ingredient("goldnugget", 10),
			Ingredient("rope", 2)
		},
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_armor_princess",
		ingredients = {
			musha_armor_original,
			Ingredient("goldnugget", 10),
			Ingredient("orangegem", 3),
			Ingredient("bearger_fur", 2)
		},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_armor_forest",
		ingredients = {
			musha_armor_original,
			Ingredient("bluegem", 5),
			Ingredient("butterfly", 5),
			Ingredient("gears", 2)
		},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_armor_shadow",
		ingredients = {
			musha_armor_original,
			Ingredient("goldnugget", 20),
			Ingredient("yellowgem", 3),
			Ingredient("livinglog", 4)
		},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_bunnyhat",
		ingredients = Get_Bunnyhat_Recipes(),
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_ironbunnyhat",
		ingredients = {
			Ingredient("musha_bunnyhat", 1, "images/inventoryimages/musha_bunnyhat.xml"),
			Ingredient("walrus_tusk", 1),
			Ingredient("orangegem", 1)
		},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_ironcathat",
		ingredients = {Ingredient("purplegem", 2), Ingredient("gears", 2)},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_princesscrown",
		ingredients = {
			musha_glowdust(4),
			Ingredient("yellowgem", 2),
			Ingredient("amulet", 1)
		},
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_phoenixhat",
		ingredients = {
			Ingredient("panflute", 1),
			Ingredient("dragon_scales", 1),
			Ingredient("yellowgem", 2),
			Ingredient("greengem", 2)
		},
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_tent",
		ingredients = {
			musha_glowdust(2),
			Ingredient("fireflies", 1),
			Ingredient("papyrus", 2),
			Ingredient("cutgrass", 15)
		},
		level = TECH.SCIENCE_TWO,
		placer = "musha_tent_placer"
	},
	{
		name = "musha_forge",
		ingredients = {
			Ingredient("musha_cristal", 1, "images/inventoryimages/musha_cristal.xml"),
			Ingredient("gears", 3),
			Ingredient("transistor", 1),
			Ingredient("livinglog", 5)
		},
		level = TECH.SCIENCE_TWO,
		placer = "musha_forge_placer"
	},
	{
		name = "musha_oven",
		ingredients = {
			musha_glowdust(3),
			Ingredient("rocks", 20),
			Ingredient("froglegs", 1),
			Ingredient("purplegem", 1)
		},
		level = TECH.SCIENCE_TWO,
		placer = "musha_oven_placer"
	},
	{
		name = "musha_moontree",
		ingredients = {
			musha_glowdust(10),
			Ingredient("livinglog", 12),
			Ingredient("musha_beefalo_egg", 1, "images/inventoryimages/musha_beefalo_egg.xml")
		},
		level = TECH.SCIENCE_TWO,
		placer = "musha_moontree_placer"
	},
	{
		name = "musha_beefalo_egg",
		ingredients = {
			musha_glowdust(6),
			Ingredient("amulet", 1),
			Ingredient("beefalowool", 20),
			Ingredient("purplegem", 4)
		},
		level = TECH.SCIENCE_ONE
	},
	{
		name = "musha_yamche_egg",
		ingredients = {Ingredient("amulet", 1), Ingredient("redgem", 8), Ingredient("bluegem", 8)},
		level = TECH.NONE
	},
	{
		name = "musha_yamche_egg2",
		ingredients = {
			Ingredient("musha_yamche_egg", 1, "images/inventoryimages/musha_yamche_egg.xml"),
			Ingredient("goldnugget", 5),
			musha_glowdust(1)
		},
		level = TECH.SCIENCE_TWO
	},
	{
		name = "musha_yamche_egg3",
		ingredients = {
			Ingredient("musha_yamche_egg2", 1, "images/inventoryimages/musha_yamche_egg2.xml"),
			Ingredient("goldnugget", 30),
			Ingredient("purplegem", 1),
			musha_glowdust(5)
		},
		level = TECH.MAGIC_TWO
	},
	{
		name = "musha_yamche_egg4",
		ingredients = {
			Ingredient("musha_yamche_egg3", 1, "images/inventoryimages/musha_yamche_egg3.xml"),
			Ingredient("goldnugget", 40),
			Ingredient("purplegem", 5),
			musha_glowdust(10)
		},
		level = TECH.MAGIC_THREE
	}
}

--还差建筑

for k, v in pairs(Musha_recipe) do
	AddRecipe(
		v.name,
		v.ingredients,
		TabMusha,
		v.level,
		v.placer or nil,
		nil,
		nil,
		v.num or nil,
		"_musha",
		not v.autoico and "images/inventoryimages/" .. (v.product or v.name) .. ".xml" or nil,
		nil,
		nil,
		v.product or nil
	)
end
